#pragma once
#include <vector>
#include "Floor.h"
#include "TicketHandler.h"

using namespace std;

//use this for the sort function to move the lowest floors to the top
class floorSort
{
public:
	bool operator()(Ticket* t1,Ticket* t2)
	{
		//BUG Walker: throws and exception
		/*if(t1->getDestination()>t2->getDestination())
		{
			return false;
		}
		return true;*/
		// Walker: proposed change
		return (t1->getDestination() > t2->getDestination());
	}
};

enum elevStates
{
	IDLE,FIRST_FLR_DELAY, UPPER_FLR_DELAY, UPPER_FLR_DELAY_OCC_UP,UPPER_FLR_DELAY_OCC_DOWN, FIRST_FLR_LOAD, UPPER_FLR_LOAD, FIRST_FLR_UNLOAD, UPPER_FLR_UNLOAD, MOVE_UP_EMPTY, MOVE_UP_OCC, 
	MOVE_DOWN_NOT_FULL, MOVE_DOWN_FULL
};

class Elevator
{
public:
	Elevator(vector <Floor>* floorVector,TicketHandler *,int elevatorID);
	~Elevator(void);
	void init(void);
	void update(int time);
private:
	vector <Floor>* floors;
	TicketHandler * ticketHand;
	priority_queue <Ticket*,vector <Ticket*>,floorSort> passengers;
	int elID;
	int timer;
	int curentFloor, targetFloor;
	elevStates curState;
	void loadPassenger(Ticket ** tick,int theTime);
	void unloadPassenger(int theTime);
	// Walker: proposed new private helper method
	//void loadPassenger(Ticket * tick, int elID, int theTime);
};

